package servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import dao.CommunityDao;
import dao.impl.CommunityDaoImpl;
import entity.Community;
import service.CommunityService;
import service.impl.CommunityServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/CSdeleteServlet")
public class CSdeleteServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=request.getParameter("id");
        CommunityService communityService=new CommunityServiceImpl();

        PrintWriter printWriter=response.getWriter();
        printWriter.print(new ObjectMapper().writeValueAsString(communityService.deleteCommunity(id)));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}

